// Login box
$(document).ready(function() {

    $(".signin").click(function(e) {
        e.preventDefault();
        $("fieldset#signin_menu").toggle();
        $(".signin").toggleClass("menu-open");
    });

    $("fieldset#signin_menu").mouseup(function() {
        return false
    });
    $(document).mouseup(function(e) {
        if($(e.target).parent("a.signin").length==0) {
            $(".signin").removeClass("menu-open");
            $("fieldset#signin_menu").hide();
        }
    });

});
//Show/hide user_panel.tpl
$(document).ready(function(){
    $("#toggle_my_data").click(function(){
        $('#my_data').slideToggle("fast");
    });
    $("#toggle_my_practice").click(function(){
        $('#my_practice').slideToggle("fast");
    });
    $("#toggle_change_data").click(function(){
        $('#change_data').slideToggle("fast");
    });
    $("#select_change_data").change(function(){
        var select = $("#select_change_data").val();
        if(select == 'album'){
            $('#change_album').slideDown();
            $('#change_email').hide();
            $('#change_faculty').hide();
            $('#change_password').hide();
        }
        else if(select == 'email'){
            $('#change_email').slideDown();
            $('#change_album').hide();
            $('#change_faculty').hide();
            $('#change_password').hide();
        }
        else if(select == 'faculty'){
            $('#change_faculty').slideDown();
            $('#change_email').hide();
            $('#change_album').hide();
            $('#change_password').hide();
        }
        else if(select == 'password'){
            $('#change_password').slideDown();
            $('#change_email').hide();
            $('#change_faculty').hide();
            $('#change_album').hide();
        }
        else{
            $('#change_email').hide();
            $('#change_faculty').hide();
            $('#change_album').hide();
            $('#change_password').hide();
        }

    });
});
//Tip script
$(document).ready(function() {
	//Tooltips
	$(".tip_trigger").hover(function(){
		tip = $(this).find('.tip');
		tip.show(); //Show tooltip
	}, function() {
		tip.hide(); //Hide tooltip
	}).mousemove(function(e) {
		var mousex = e.pageX + 20; //Get X coodrinates
		var mousey = e.pageY + 20; //Get Y coordinates
		var tipWidth = tip.width(); //Find width of tooltip
		var tipHeight = tip.height(); //Find height of tooltip

		//Distance of element from the right edge of viewport
		var tipVisX = $(window).width() - (mousex + tipWidth);
		//Distance of element from the bottom of viewport
		var tipVisY = $(window).height() - (mousey + tipHeight);

		if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
			mousex = e.pageX - tipWidth - 20;
		}if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
			mousey = e.pageY - tipHeight - 20;
		}
		tip.css({top: mousey, left: mousex});
	});
});

//register.tpl
$(document).ready(function()
{

$('#company_radio').click(function()
{
        $('#student_block').hide();
        $('#company_block').show();
});

$('#student_radio').click(function()
{
        $('#company_block').hide();
        $('#student_block').show();
});


$("#s_faculty").change(function()
{
var id=$(this).val();
var dataString = 'id='+id;

$.ajax
({
type: "POST",
url: "functions/getSpecialization.php",
data: dataString,
cache: false,
success: function(html)
{
$("#s_specialization").html(html);
}
});

});

});

//bookmarks
$(document).ready(function() {
	$("ul.fade").not(":first").hide();
	$("a.link").click(function(){
			$(".fade:visible").hide();
			$(this).parent().next('.fade').fadeIn();
			/*$(this).parent('.kategoria').next('ul').fadeIn();*/
			return false;
	});

			<!-- blysk na obrazkach -->
					$(".kategoria a.link").fadeTo("fast", .8);
						$(".kategoria a.link").hover(function(){
															$(this).fadeTo("fast", 1);
													},function(){
															$(this).fadeTo("fast", .8);
													});


 });